﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Data.Car_Rental;
using Web.Commons;

namespace Car_Rental.Controllers
{
    public class NewsController : BaseController
    {
        INewsRepository iNewsRepository = null;
        public NewsController()
        {
            iNewsRepository = new NewsRepository();
        }
        //
        // GET: /News/

        public ActionResult Index(int? page)
        {
            VP = new Entity.VPredication();
            PP = new Entity.PagingParam(page ?? 1, base.PageSize);
            var model = iNewsRepository.GetNews(VP, PP);
            return View(model);
        }
        public ActionResult Details(int? id)
        {
            if (!id.HasValue)
                return RedirectToAction("Index");
            var model = iNewsRepository.GetModelForBackground().FirstOrDefault(i => i.NewsID == id);

            return View(model);
        }
    }
}
